/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.raflik.queryxml.ui.cellrenderer;

import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JList;
import pl.raflik.queryxml.serializer.QueryResultSerializer;
import pl.raflik.queryxml.ui.SelectableComboBoxRenderer;

/**
 *
 * @author raflik
 */
public class SerializerListCellRenderer extends SelectableComboBoxRenderer {

    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

        if (value instanceof QueryResultSerializer) {
            final QueryResultSerializer queryResultSerializer = (QueryResultSerializer) value;
            final String outputType = queryResultSerializer.supportedOutputType();
            label.setText(outputType);
            label.setToolTipText(outputType);
        }
        return label;
    }

}
